package com.wsx.rpc.cloud.controller;

import com.wsx.rpc.api.ApiRequest;
import com.wsx.rpc.api.ApiResponse;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author wangshuaixin
 * @Title: com.wsx.rpc.cloud.controller.CloudController
 * @Description: TODO
 * @date 2018/10/30
 */
@RestController
@RequestMapping("/cloud/test")
public class CloudController {

    @RequestMapping(
            value = "/mestic",
            method = {RequestMethod.POST},
            produces = {MediaType.APPLICATION_JSON_UTF8_VALUE},
            consumes = {MediaType.APPLICATION_JSON_UTF8_VALUE}
    )
    public ApiResponse exec(@RequestBody ApiRequest apiRequest) {
        ApiResponse response = new ApiResponse();
        response.setCode(apiRequest.getCode() + 1);
        response.setMsg(apiRequest.getMsg() + 1);
        response.setDays(apiRequest.getDays());

        response.setList(apiRequest.getList());
        response.setMap(apiRequest.getMap());
        response.setMoney(apiRequest.getMoney() + 1);
        response.setName(apiRequest.getName() + 1);
        response.setStatus(apiRequest.getStatus() + 1);
        response.setTime(new Date());

        response.setTitle(apiRequest.getTitle() + 1);
        try {
            Thread.sleep(5);
        } catch (Exception e) {

        }
        return response;
    }


}
